<?php
$row	=	array();
if(isset($_GET['id']) && intval($_GET['id']) != 0) 
{
	$q	=	mysql_query("SELECT * FROM tailieu WHERE tl_id=".intval($_GET['id']));
	$num	=	mysql_num_rows($q);
	if($num == 1)
	{
		$row	=	mysql_fetch_array($q);
		//print_r($_COOKIE);
		if(!isset($_COOKIE['view_'.$row['tl_id']]) || $_COOKIE['view_'.$row['tl_id']] != $row['id']){
			mysql_query("UPDATE tailieu SET luot_xem=".intval($row['luot_xem']+1)." WHERE tl_id=".intval($_GET['id']));
			//setcookie("view_".$row['tl_id'], "asdsa", time()+60);
		}
	}
}

if($row):
?>
<table>
	<tr>
		<td><?php echo $row['tl_title'];?></td>
	</tr>
	<tr>
		<td><?php echo $row['tl_des'];?></td>
	</tr>
	<tr>
		<td>
		<?php if(isset($_SESSION['_user'])):?>
		<a href="download.php?id=<?php echo $row['tl_id'];?>"><img src="images/btn127x29.gif" /></a>
		<?php endif;?>
		</td>
	</tr>
	<tr>
		<td>
			<?php 
			$mem	=	get_mem_info($row['t_id']);
			?>
			Chia sẻ: &nbsp;<?php echo ($mem ? $mem['t_user'] : 'asdas');?> |&nbsp;Ngày: &nbsp;<?php echo date('d/m/Y',strtotime($row['tl_date']));?>&nbsp;|&nbsp;Lượt xem:<?php echo $row['luot_xem'];?> | Yêu thích: 0 | Bình chọn: 0 | Bình luận: 0 | Download: <?php echo $row['luot_tai'];?>
		</td>
	</tr>
	<tr>
		<td>
		<iframe src="http://docs.google.com/viewer?url=<?php echo $CONFIG['site_url'].$row['tl_link'];?>&embedded=true" style="width:600px; height:500px;" frameborder="0"></iframe>
		
		</td>
	</tr>
</table>

<h2>Tài liệu liên quan</h2>
<ul>
<?php
	$q1	=	mysql_query("SELECT * FROM tailieu WHERE tl_id <> ".$row['tl_id']." AND pl_id=".intval($row['pl_id'])." ORDER BY tl_date DESC LIMIT 10");
	while($r	=	mysql_fetch_array($q1)):
?>
	<li><a href="index.php?act=view_doc&id=<?php echo $r['tl_id'];?>"><?php echo $r['tl_title'];?></a></li>
<?php endwhile;?>
</ul>

<?php endif;?>